<template>
	<view>
		<u-navbar back-text="返回"
		:background="background"
		 title="发布页面"></u-navbar>
		<u-toast ref="uToast" />
		<postNav @titleClass='getClass'></postNav>
		<!-- 分割线 -->
		<u-divider color="#62C26C">话题标题</u-divider>
		<u-input v-model="postMsg.title" placeholder="请输入..."/>
		<u-divider color="#62C26C">话题简介</u-divider>
		<u-input v-model="postMsg.outline"  placeholder="请输入..."/>
		<u-divider color="#62C26C">话题内容</u-divider>
		<textarea v-model="postMsg.body" class="u-p-20" placeholder="分享新鲜事..." /><u-toast ref="uToast" class="tanchuang"/>
		<upLoadF ></upLoadF>
		<button type="primary" @click="postTitle">确认发布</button>	
		<footNav :currents='2'></footNav>
	</view>
</template>

<script>
	import footNav from '@/components/footNav/footNav.vue'
	import upLoadF from '@/components/uploadFile/uploadFile.vue'
	import postNav from '@/components/postNav/postNav.vue'
	export default {
		components:{
			upLoadF,
			footNav,
			postNav
		},
		data() {
			return {
				background: {
					backgroundImage: 'linear-gradient(45deg, rgb(28, 187, 180), rgb(141, 198, 63))'
				},
				postMsg:{
					title:'',
					body:'',
					outline:'',
					cid:'',
					imgUrl:"http://fc.php800.cn/upload/img_2021-11-11_18:01:09_102023921083722.jpg",
					password:'',
					isclose:'',
				}
			}
		},
		created(){
			
		},
		methods:{		
			getClass(data){//处理子组件传来的信息
				if(data.password){this.postMsg.password=data.password}
				if(data.isclose){this.postMsg.isclose=data.isclose}
				this.postMsg.cid=data.arr.join(',')
			},
			postTitle(){//发布文章
				this.postMsg.imgUrl=this.vuex_imgUrl
				this.$api.setNewTitle(this.postMsg).then(
				   res=>{
					   if(res!==0){
						   this.$refs.uToast.show({
					  	duration: 3000,
					  	title: '发布成功',
					  	type: 'success',
						url:'/pages/index/index'
					  });
					   }
					  
				   },
				   err=>{
					   console.log(err)
				   }
				
				)
			}
			
			
		}
	}
</script>

<style lang="scss">

.tanchuang{
	width: 50vw;
	margin-left: 300rpx;
}

</style>
